<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1"
	action="<%-- ${systemctx}/sample/saveSample.web --%>" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.servicemanagement.title") %><span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.title") %><span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.save.title") %></div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicenum") %></label>
						<span>${charge.servicenum}</span>
					</li>
					<li>
						<i></i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicename") %></label>
						<span>${charge.servicename}</span>
					</li>
				</ul>
				
				<ul>
					<li>
						<i>*</i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.proposed") %></label>
						<span>
							<input type="checkbox" id="isproposedcheck" name="isproposedcheck" class="check-box"/>
						</span>
					</li>
					<li>
						<i>*</i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.proposedprice") %></label>
						<span><input type="text" id="proposedprice" name="proposedprice" value="" class="iss_amount"/></span>
					</li>
				</ul>
				
				<ul>
					<li>
						<i>*</i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.month") %></label>
						<span>
							<input type="checkbox" id="ismonthcheck" name="ismonthcheck" class="check-box"/>
						</span>
					</li>
					<li>
						<i>*</i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.monthprice") %></label>
						<span><input type="text" id="monthprice" name="monthprice" value="" class="iss_amount"/></span>
					</li>
				</ul>
			</div>
			<div class="button-group">
				<input type="hidden" id="isproposed" name="isproposed" value="" />
				<input type="hidden" id="ismonth" name="ismonth" value="" />
				<input type="hidden" id="serviceid" name="serviceid" value="${serviceid}" />
				<input type="button" class="btn btn-default" id="butSave" name="butSave" value="<%=MessageResourcesUtils.getMessage(request, "common.button.save") %>" />
				<input type="button" class="btn btn-default"  id="butReturn" name="butReturn" value='<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>' />
				
			</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function(){
		var proposedprice_amount = '';
		var monthprice_amount = '';
		
		//若用户输入每月价格或者每笔价格，触发失去焦点事件，获得想对应的金额  Start //
		$('#proposedprice').blur(function(){
			proposedprice_amount = $('#proposedprice').val();
		})
		$('#monthprice').blur(function(){
			monthprice_amount = $('#monthprice').val();
		})
		//若用户输入每月价格或者每笔价格，触发失去焦点事件，获得想对应的金额  End //
		
		//若用户勾选按月收取或者按笔收取时，触发变更事件    Start //
		$('#isproposedcheck').change(function(){
			//如果选中，也填写，则赋值
			if($("#isproposedcheck").prop("checked")){
				$('#isproposed').val('1');
				$('#proposedprice').numberbox('setValue','');
				proposedprice_amount = '';
			}else{
				$('#isproposed').val('');
				$('#proposedprice').numberbox('setValue','');
				proposedprice_amount = '';
			}
		})
		
		$('#ismonthcheck').change(function(){
			//如果选中，也填写，则赋值
			if($("#ismonthcheck").prop("checked")){
				$('#ismonth').val('1');
				$('#monthprice').numberbox('setValue','');
				monthprice_amount = '';
			}else{
				$('#ismonth').val('');
				$('#monthprice').numberbox('setValue','');
				monthprice_amount = '';
			}
		})
		//若用户勾选按月收取或者按笔收取时，触发变更事件    End //
		
		$('#butSave').click(function() {
			//如果 两个单选框都不选择的话，就提示
			if(!($("#isproposedcheck").prop("checked")) && !($("#ismonthcheck").prop("checked"))){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert")%>');
				return;
			}
			
			var proposedprice = $.reverseFormatAmount(proposedprice_amount);
			var monthprice = $.reverseFormatAmount(monthprice_amount);
			//如果只选中单选框，但不填写价格，就提示
			if($("#isproposedcheck").prop("checked") && proposedprice ==''){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert1")%>');
				return;
			}else if(!$("#isproposedcheck").prop("checked") && proposedprice !=''){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert3")%>');
				return;
			}else if($("#ismonthcheck").prop("checked") && monthprice == ''){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert2")%>');
				return;
			}else if(!$("#ismonthcheck").prop("checked") && monthprice != ''){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert4")%>');
				return;
			}
			
			if(eval(proposedprice) == 0){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert5")%>');
				return;
			}
			if(eval(monthprice) == 0){
				alert('<%=MessageResourcesUtils.getMessage(request,"alertinfo.chargemanage.Add.alert6")%>');
				return;
			}
			if(confirm('<%=MessageResourcesUtils.getMessage(request,"alertinfo.common.jsp.alert1")%>') ){
				// 显示进度条
				showSending();
				form1.action="${systemctx}/dailyoperation/chargemanage/addCharge.web?proposedprice="+proposedprice+"&monthprice="+monthprice;
				form1.submit();
			}
		});
		
		$("#butReturn").click(function(){
			parent.document.location.reload();
			$.fn.closeIssWindow();
		});
	});
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>